package models

import (
	"192.168.1.75/go-pkg/helper"
	"gorm.io/gorm"
)

// DeviceHeatMap 设备热力图
type DeviceHeatMap struct {
	ID                 string  `json:"id" gorm:"column:id;primaryKey;type:int;size:64;comment:主键"`
	RobotID            string  `json:"robot_id" gorm:"column:robot_id;type:string;size:40;index:idx_robotid_mapid,priority:1;index:idx_robotID_createdMinute,priority:1;comment:设备id"`
	PosX               float32 `json:"pos_x" gorm:"column:pos_x;type:float;size:32;comment:机器人位置x"`
	PosY               float32 `json:"pos_y" gorm:"column:pos_y;type:float;size:32;comment:机器人位置y"`
	PosDirection       float32 `json:"pos_direction" gorm:"column:pos_direction;type:float;size:32;机器人位置direction"`
	MapName            string  `json:"map_name" gorm:"column:map_name;index:map_name;type:string;size:100;comment:地图名称"`
	MapID              string  `json:"map_id" gorm:"column:map_id;index:map_id;type:int;size:64;index:idx_robotid_mapid,priority:2;comment:地图id"`
	CreatedOrderNumber int64   `json:"created_order_number" gorm:"column:created_order_number;type:int;size:64;创建订单数"`
	PaidOrderNumber    int64   `json:"paid_order_number" gorm:"column:paid_order_number;type:int;size:64;comment:已支付订单"`
	FaceCount          int64   `json:"face_count" gorm:"column:face_count;type:int;size:64;comment:总的曝光量"`
	FaceCountFront     int64   `json:"face_count_front" gorm:"column:face_count_front;type:int;size:64;comment:前置曝光量"`
	FaceCountLeft      int64   `json:"face_count_left" gorm:"column:face_count_left;type:int;size:64;comment:左侧曝光量"`
	FaceCountRight     int64   `json:"face_count_right" gorm:"column:face_count_right;type:int;size:64;comment:右侧曝光量"`
	CreatedDate        string  `json:"created_date,omitempty" gorm:"column:created_date;index:created_date;type:string;size:10;comment:创建日期"`
	CreatedMinute      string  `json:"created_minute,omitempty" gorm:"column:created_minute;index:idx_robotID_createdMinute,priority:2;type:string;size:20;comment:创建分钟时间"`
	CreatedAt          int64   `json:"created_at" gorm:"autoCreateTime;column:created_at;index:created_at;type:int;size:64;comment:创建时间"`
}

// TableName 表名
func (DeviceHeatMap) TableName() string {
	return "device_heat_map"
}

// BeforeCreate 自增id
func (d *DeviceHeatMap) BeforeCreate(tx *gorm.DB) (err error) {
	if d.ID != "" {
		return nil
	}
	// 用户id为空时，自动添加用户id
	uuid, err := helper.UUID{}.String()
	if err != nil {
		return err
	}
	d.ID = uuid
	return nil
}

// 模式自动注册
func init() {
	Models = append(Models, &DeviceHeatMap{})
}

type DeviceHeatMapTpl struct {
	DeviceHeatMap
}

func (DeviceHeatMapTpl) TableName() string {
	return "device_heat_map_tpl"
}
func (DeviceHeatMapTpl) Unimplemented() {

}
